package com.course.finalproject.model;

import android.os.Parcel;
import android.os.Parcelable;

public class CurrentWeather extends Weather implements Parcelable {

	protected int cTemp;
	protected int fTemp;
	protected String relativeHumidity;
	protected int windMph;
	protected int windKph;
	protected String windDir;
	protected String location;
	
	/**
	 * Constructor.
	 * 
	 * @param condition
	 * @param icon
	 * @param cTemp
	 * @param fTemp
	 * @param humidity
	 * @param windMph
	 * @param windKph
	 * @param windDir
	 * @param location
	 */
	public CurrentWeather( String condition, String icon, int cTemp, int fTemp, String relativeHumidity,
						   int windMph, int windKph, String windDir, String location) {
		super(condition, icon);
		this.cTemp = cTemp;
		this.fTemp = fTemp;
		this.relativeHumidity = relativeHumidity;
		this.windMph = windMph;
		this.windKph = windKph;
		this.windDir = windDir;
		this.location = location;
	}
	
	/**
	 * Constructor from a parcel.
	 * 
	 * @param in The parcel object to reconstruct a weather forecast object.
	 */
	private CurrentWeather(Parcel in) {
		this.condition = in.readString();
		this.icon = in.readString();
		this.cTemp = in.readInt();
		this.fTemp = in.readInt();
		this.relativeHumidity = in.readString();
		this.windMph = in.readInt();
		this.windKph = in.readInt();
		this.windDir = in.readString();
		this.location = in.readString();
	}
	
	/**
	 * Returns the temperature in Celsius degrees.
	 * 
	 * @return The temperature in Celsius degrees.
	 */
	public int getCelTemp() {
		return cTemp;
	}
	
	/**
	 * Returns the temperature in Fahrenheit degrees.
	 * 
	 * @return The temperature in Fahrenheit degrees.
	 */
	public int getFhaTemp() {
		return fTemp;
	}
	
	/**
	 * Returns the relative humidity.
	 * 
	 * @return The relative humidity.
	 */
	public String getRelativeHumidity() {
		return relativeHumidity;
	}
	
	/**
	 * Returns the wind velocity in Mph.
	 * 
	 * @return The wind velocity in Mph.
	 */
	public int getWindMph() {
		return windMph;
	}
	
	/**
	 * Returns the wind velocity in Kph.
	 * 
	 * @return The wind velocity in Kph.
	 */
	public int getWindKph() {
		return windKph;
	}
	
	/**
	 * Returns the direction of the wind.
	 * 
	 * @return The direction of the wind.
	 */
	public String getWindDir() {
		return windDir;
	}
	
	/**
	 * Returns the location in format: "City, Country".
	 * 
	 * @return The city and country location.
	 */
	public String getLocation() {
		return location;
	}
	
	@Override
	public boolean isCurrent() {
		return true;
	}
	
	@Override
	public String getWeekDay() {
		return "Today";
	}
	
	@Override
	public String getCelTempReadable() {
		return cTemp + "º C";
	}

	@Override
	public String getFahTempReadable() {
		return fTemp + "º F";
	}

	@Override
	public String getHumidityReadable() {
		return "Humidity: " + relativeHumidity;
	}

	@Override
	public String getWindReadable() {
		return "Wind: " + windKph + " Kph " + windDir;
	}
	
	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(condition);
		dest.writeString(icon);
		dest.writeInt(cTemp);
		dest.writeInt(fTemp);
		dest.writeString(relativeHumidity);
		dest.writeInt(windMph);
		dest.writeInt(windKph);
		dest.writeString(windDir);
		dest.writeString(location);
	}
	
	public static final Parcelable.Creator<CurrentWeather> CREATOR = new Parcelable.Creator<CurrentWeather>() {
		public CurrentWeather createFromParcel(Parcel in) {
		    return new CurrentWeather(in);
		}
		
		public CurrentWeather[] newArray(int size) {
		    return new CurrentWeather[size];
		}
	};

}
